package com.alibaba.citrus.cr.common.enums.ordercenter;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Getter
public enum FulfillmentStatusEnum {

    FAIL_FULFILLMENT("-1", "履约失败"),
    BEFORE_FULFILLMENT("1", "待履约"),
    PARTIAL_FULFILLMENT("2", "部分履约"),
    COMPLETED("3", "已完成");

    private final String code;
    private final String desc;

    FulfillmentStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static FulfillmentStatusEnum of(String code) {
        return Arrays.stream(FulfillmentStatusEnum.values()).filter(source -> Objects.equals(code, source.getCode())).findFirst().orElse(null);
    }

    public static List<String> codes() {
        return Arrays.stream(FulfillmentStatusEnum.values()).map(FulfillmentStatusEnum::getCode).collect(Collectors.toList());
    }
}
